Skip to content

Conversation

raziel057
Copy link

@raziel057 raziel057 commented Oct 3, 2025

Support for read & write of Image in Cell - Related to #4014

I must admit it was really complex to understand the relations between all xml (richData) files that have to be created / updated. I lost a lot of time comparing the structure with files edited in Excel and specifically figuring out the metadata.xml file had to be largely changed as soon as images are added in cells.

This branch is based on #4664

This is:

  • a bugfix
  • a new feature
  • refactoring
  • additional unit tests

Checklist:

  • Changes are covered by unit tests
    • Changes are covered by existing unit tests
    • New unit tests have been added
  • Code style is respected
  • Commit message explains why the change is made (see https://github.com/erlang/otp/wiki/Writing-good-commit-messages)
  • CHANGELOG.md contains a short summary of the change and a link to the pull request if applicable
  • Documentation is updated as necessary

Support for read and write of Image in Cell - Related to #4014

Why this change is needed?

When an image is inserted in a cell in an XLSX document, PhpSpreadsheet is currently not able to read it. This PR allow to collect those images in order to find them when calling $objWorksheet->getInCellDrawingCollection(). It's also possible to get the Drawing object from from the related Cell.

The code is covered by tests and have been tested in real application - As shown bellow:
image

When I import the file with image inserted in the Cell, I have it now in $objWorksheet->getInCellDrawingCollection():

image

@raziel057 raziel057 mentioned this pull request Oct 3, 2025
11 tasks
Comment on lines 966 to 967
$objDrawing->setOffsetX(0);
$objDrawing->setOffsetY(0);
Copy link

@rapaelector rapaelector Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those can be remove as it is by default as 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants